package com.cnswhy.cloud.server.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.*;
import com.cnswhy.cloud.common.core.base.entity.Entity;
import com.cnswhy.cloud.server.common.entity.enumeration.IotType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.cnswhy.cloud.common.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 
 * </p>
 *
 * @author cnswhy
 * @since 2021-03-24
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("t_iot_terminal_info")
@ApiModel(value = "IotTerminalInfo", description = "")
@AllArgsConstructor
public class IotTerminalInfo extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 终端编号
     */
    @ApiModelProperty(value = "终端编号")
    @NotEmpty(message = "终端编号不能为空")
    @Length(max = 20, message = "终端编号长度不能超过20")
    @TableField(value = "terminal_id", condition = LIKE)
    @Excel(name = "终端编号")
    private String terminalId;

    /**
     * 0失效 1 生效
     */
    @ApiModelProperty(value = "0失效 1 生效")
    @NotNull(message = "0失效 1 生效不能为空")
    @TableField("status")
    @Excel(name = "0失效 1 生效")
    private Integer status;

    /**
     * 终端类型
     */
    @ApiModelProperty(value = "终端类型")
    @NotEmpty(message = "终端类型不能为空")
    @Length(max = 255, message = "终端类型长度不能超过255")
    @TableField(value = "iot_type", condition = LIKE)
    @Excel(name = "终端类型")
    private IotType iotType;

    /**
     * 激活状态0 未激活 1 已激活 
     */
    @ApiModelProperty(value = "激活状态0 未激活 1 已激活 ")
    @TableField("active_status")
    @Excel(name = "激活状态0 未激活 1 已激活 ")
    private Integer activeStatus;

    /**
     * 关联服务商
     */
    @ApiModelProperty(value = "关联服务商")
    @TableField(value = "customer_id",updateStrategy = FieldStrategy.IGNORED)
    @Excel(name = "关联服务商")
    private Long customerId;

    /**
     * 关联商家
     */
    @ApiModelProperty(value = "关联商家")
    @TableField(value = "merchant_id",updateStrategy = FieldStrategy.IGNORED)
    @Excel(name = "关联商家")
    private Long merchantId;

    /**
     * 二维码
     */
    @ApiModelProperty(value = "二维码")
    @Length(max = 255, message = "二维码长度不能超过255")
    @TableField(value = "qr_code", condition = LIKE)
    @Excel(name = "二维码")
    private String qrCode;

    /**
     * 批次号
     */
    @ApiModelProperty(value = "批次号")
    @Length(max = 255, message = "批次号长度不能超过255")
    @TableField(value = "batch_order_id", condition = LIKE)
    @Excel(name = "批次号")
    private String batchOrderId;

    /**
     * 配比
     */
    @ApiModelProperty(value = "配比")
    @TableField("split")
    @Excel(name = "配比")
    private Long split;

    @TableField(exist = false)
    private Customer customer;
    @TableField(exist = false)
    private Merchant merchant;
    @TableField(exist = false)
    private boolean customerFlag;
    @TableField(exist = false)
    private boolean merchantFlag;
    @TableField(exist = false)
    private boolean selfFlag;

    @Builder
    public IotTerminalInfo(Long id, LocalDateTime createTime, LocalDateTime updateTime, Long updateUser, Long createUser, 
                    String terminalId, Integer status, IotType iotType, Integer activeStatus, Long customerId,
                    Long merchantId, String qrCode, String batchOrderId, Long split) {
        this.id = id;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.updateUser = updateUser;
        this.createUser = createUser;
        this.terminalId = terminalId;
        this.status = status;
        this.iotType = iotType;
        this.activeStatus = activeStatus;
        this.customerId = customerId;
        this.merchantId = merchantId;
        this.qrCode = qrCode;
        this.batchOrderId = batchOrderId;
        this.split = split;
    }

}
